package cn.gok;

import java.util.Scanner;

/**
 * @ClassName 内部类
 * @Description TODO
 * @Author HP
 * @Date 9:49 2022/7/6
 * @Version 1.0
 **/
class Teacher{
    public int teach(){
        System.out.println("教师教书");
        return 10;
    }
}
class Animal{
    public void call(){
        System.out.println("叫声");
    }
}
public class 内部类 {
    public static void main(String[] args) {
//        System.out.println("输入叫声");
//        String sound = new Scanner(System.in).nextLine();
//        Animal animal = new Animal(){
//            @Override
//            public void call() {
//                System.out.println(sound);;
//            }
//        };
//
//        animal.call();
        Teacher teacher = new Teacher(){
            @Override
            public int teach() {
                return 20;
            }
        };
        System.out.println(teacher.teach());
        Teacher teacher1 = new Teacher(){
            @Override
            public int teach() {
                return 30;
            }
        };
        System.out.println(teacher1.teach());
    }


}
//    interface Library{
//        void borrowBook();
//        void returnBook();
//    }
//    Library library = new Library() {
//        @Override
//        public void borrowBook() {
//            System.out.println("借书");
//        }
//
//        @Override
//        public void returnBook() {
//            System.out.println("还书");
//        }
//    };

